Skip to content

fix(sessions): auto-recover + report the chat SessionView render-loop crash#3747

Closed
puemos wants to merge 2 commits into
mainfrom
posthog-code/session-view-autorecover-boundary
Closed

fix(sessions): auto-recover + report the chat SessionView render-loop crash#3747
puemos wants to merge 2 commits into
mainfrom
posthog-code/session-view-autorecover-boundary

Conversation

@puemos

@puemos puemos commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Problem

The task Chat panel sometimes shows "Something went wrong / Minified React error #185" (Maximum update depth exceeded) when navigating back to a task, and then stays stuck on the error fallback until the user manually clicks Try again. This is caught by the SessionView error boundary and has recurred across many users on recent packaged builds; it was reported in #2165, whose own note is the key clue — "Clicking Try again recovered the session… the error is in a render path" — i.e. the render loop is transient: it trips React's limit once and then clears on the next mount.

Why the user is stuck — two issues on main:

  1. The SessionView boundary keys recovery on resetKey={taskId}, which doesn't change when you navigate back to the same task, so a transient error strands the user on the fallback until they retry by hand.
  2. That boundary is wired to the bare ErrorBoundary primitive (no onError), so these crashes no longer report to error tracking — the historical boundary_name:"SessionView" events came from older builds that used the telemetry shell wrapper. We're currently blind to them.

Refs #2165

Changes

  • ErrorBoundary primitive — add an opt-in, bounded autoRecover. On catch it reports via onError first (observability preserved), then schedules up to 2 self-resets — automating the manual "Try again" that Chat crashes with React error 185 (max update depth) #2165 says already works. While a recovery is pending it renders nothing instead of flashing the red error UI for a one-frame blip. A persistent loop still lands on the manual fallback (no unbounded retry storm), and the budget refills after a healthy stretch.
  • SessionView boundary (TaskLogsPanel) — point it at the telemetry-reporting shell ErrorBoundary and enable autoRecover. This restores error-tracking visibility and auto-heals the transient loop so returning to a task no longer strands the user.

Behaviour is unchanged for every other boundary (autoRecover defaults off).

Note: this does not change the underlying (layout-timing) loop trigger, which needs the real app to reproduce and isolate; the restored telemetry will confirm whether it still fires so the root cause can be chased as a follow-up.

How did you test this?

Added packages/ui/src/primitives/ErrorBoundary.test.tsx (Vitest + Testing Library, real timers) which:

  • replicates the defect — without autoRecover, the boundary stays on the fallback after the transient condition clears (same resetKey, no manual retry);
  • verifies the fix — autoRecover clears a transient error with no manual retry and reports it first; a persistent loop is bounded and ends on the manual fallback; manual retry still works after auto-recovery is exhausted.

Ran locally (all green):

  • vitest run src/primitives/ErrorBoundary.test.tsx src/shell/ErrorBoundary.test.tsx — 14 passed
  • biome check on the changed files — clean
  • pnpm --filter @posthog/ui typecheck — clean

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

… crash

The task Chat panel sometimes shows "Something went wrong / Minified React
error #185" (Maximum update depth exceeded) when navigating back to a task, and
stays stuck on the fallback. Issue #2165 notes the loop is transient — "Try
again recovers it" — so the render loop trips once and clears on the next mount.

Two problems on `main`:

- The SessionView boundary keys recovery on `resetKey={taskId}`, which doesn't
  change when you return to the same task, so a transient error strands the user
  until they manually retry.
- That boundary was wired to the bare `ErrorBoundary` primitive (no `onError`),
  so these crashes no longer report to error tracking — the historical
  `boundary_name:"SessionView"` events came from older builds using the shell
  wrapper.

Changes:
- Add opt-in, bounded `autoRecover` to the `ErrorBoundary` primitive. On catch it
  reports via `onError` first, then schedules up to 2 self-resets (replaying the
  manual "Try again"); while pending it renders nothing instead of flashing the
  error UI. A persistent loop still lands on the manual fallback — no unbounded
  retry storm — and the budget refills after a healthy stretch.
- Point the SessionView boundary at the telemetry-reporting shell `ErrorBoundary`
  and enable `autoRecover`, restoring observability and auto-healing the
  transient loop.

Does not change the underlying (layout-timing) loop trigger, which needs the
real app to reproduce; restored telemetry will confirm whether it still fires.

Refs #2165

Generated-By: PostHog Code
Task-Id: 24d17b80-ad39-4217-9eb6-dcc5ad043fb8
@trunk-io

trunk-io Bot commented Jul 23, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 35c0a42.

@posthog

posthog Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

👋 Visual changes detected for this PR.

Review and approve in PostHog Visual Review

If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix.

Generated-By: PostHog Code
Task-Id: 24d17b80-ad39-4217-9eb6-dcc5ad043fb8
@puemos puemos closed this Jul 23, 2026
@puemos
puemos deleted the posthog-code/session-view-autorecover-boundary branch July 23, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant